package com.sixth.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sixth.entity.Course;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.List;

@Component
public interface CourseDao extends BaseMapper<Course> {
    //查询所有课程
    //@Select("select c.cover,c.title,s.title,c.price,c.status from edu_course c join edu_subject s on c.subject_id=s.id")
    List<Course> findCourse(@Param("title")  String title,@Param("status")  String status);

    @Update("update edu_course set status=#{status} where id=#{id}")
    int updateStatus(@Param("id")String id,@Param("status") String status);

    //编辑
    @Update("update edu_course c join edu_course_description cd on c.id=cd.id set c.title=#{title},c.price=#{price},cd.description=#{description} where c.id=#{id}")
    int updateCourse(@Param("price") Double price,@Param("id") String id,@Param("title") String title,@Param("description") String description);


    int updateStatusID(@Param("id")String id);

    int updateStatus01(@Param("id")String id);

    //前台课程中心 头部
    @Select("select * FROM edu_subject WHERE parent_id=0 and status_id=1")
    List<Course> selectMenu();

    //前台菜单
    List<Course> fontFindCourse(@Param("title") String title,@Param("price") Double price);

    List<Course> getCoursByTeacherPhone(@Param("teacherMobile") String teacherMobile,@Param("checkStatus") String checkStatus);
}